/// 请求 * 系统配置-项目维护-站点配置

import type { Site, SiteDetail, SiteEntity, SiteParmas } from './types'
import { request } from '@/helpers'

export * from './types'

/**
 * 站点列表 查询
 */
export async function apiQuerySitePage(params: PaginationParams<SiteParmas>) {
  return request<Site>(
    '/fjfr/frsgmy_system_configuration/project_setting/findAllSites',
    {
      method: 'POST',
      data: params,
    },
    'page',
  )
}

/**
 * 站点 新增
 */
export function apiAddSite(params: SiteEntity) {
  const url = '/fjfr/frsgmy_system_configuration/project_setting/site/add'
  return request(url, {
    method: 'POST',
    data: params,
  }, 'result')
}

/**
 * 站点 删除
 */
export function apiDeleteSite(siteId: number) {
  const url = `/fjfr/frsgmy_system_configuration/project_setting/site/delete`
  return request(url, {
    method: 'POST',
    data: { siteId },
  }, 'result')
}

/**
 * 站点 查询绑定设备
 */
export function apiQueryBindDeviceBySiteId(siteId: number) {
  const url = `/fjfr/frsgmy_system_configuration/project_setting/site/bindDevice/${siteId}`
  return request(url, {
    method: 'POST',
  }, 'result')
}

/**
 * 站点 详情
 */
export function apiQuerySite(siteId: number) {
  const url = `/fjfr/frsgmy_system_configuration/project_setting/site/detail`
  return request<SiteDetail>(url, {
    method: 'POST',
    data: { siteId },
  })
}

/**
 * 站点 修改
 */
export function apiMergeSite(params: SiteEntity) {
  const url = `/fjfr/frsgmy_system_configuration/project_setting/site/edit`
  return request(url, {
    method: 'POST',
    data: params,
  }, 'result')
}
